home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt32s2.arc / PIBDUMBT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1985-10-15  |  6.7 KB  |  144 lines

  1. (*----------------------------------------------------------------------*)
  2. (*          PIBDUMBT.PAS --- Emulate Dumb Terminal for PIBTERM          *)
  3. (*----------------------------------------------------------------------*)
  4. (*                                                                      *)
  5. (*  Author:  Philip R. Burns                                            *)
  6. (*  Version: 1.0   (January, 1985)                                      *)
  7. (*           2.0   (June, 1985)                                         *)
  8. (*           3.0   (October, 1985)                                      *)
  9. (*           3.1   (October, 1985)                                      *)
  10. (*  Systems: For MS-DOS on IBM PCs and close compatibles only.          *)
  11. (*           Note:  I have checked these on Zenith 151s under           *)
  12. (*                  MSDOS 2.1 and IBM PCs under PCDOS 2.0.              *)
  13. (*                                                                      *)
  14. (*  Needs:   The Menu routines from PIBMENUS.PAS, communications        *)
  15. (*           routines from PIBASYNC.PAS, and various global variables   *)
  16. (*           from PIBTERM.PAS.                                          *)
  17. (*                                                                      *)
  18. (*  History: Original with me.                                          *)
  19. (*                                                                      *)
  20. (*           Suggestions for improvements or corrections are welcome.   *)
  21. (*           Please leave messages on Gene Plantz's BBS (312) 882 4145  *)
  22. (*           or Ron Fox's BBS (312) 940 6496.                           *)
  23. (*                                                                      *)
  24. (*           If you use this code in your own programs, please be nice  *)
  25. (*           and give proper credit.                                    *)
  26. (*                                                                      *)
  27. (*----------------------------------------------------------------------*)
  28.  
  29. OVERLAY PROCEDURE Emulate_Dumb_Terminal;
  30.  
  31. (*----------------------------------------------------------------------*)
  32. (*                                                                      *)
  33. (*     Procedure:  Emulate_Dumb_Terminal                                *)
  34. (*                                                                      *)
  35. (*     Purpose:    Controls dumb terminal emulation                     *)
  36. (*                                                                      *)
  37. (*     Calling Sequence:                                                *)
  38. (*                                                                      *)
  39. (*        Emulate_Dumb_Terminal;                                        *)
  40. (*                                                                      *)
  41. (*      Calls:   Async_Send                                             *)
  42. (*               Async_Receive                                          *)
  43. (*               KeyPressed                                             *)
  44. (*               Process_Command                                        *)
  45. (*               Display_Character                                      *)
  46. (*               ClrScr                                                 *)
  47. (*               Async_Buffer_Full                                      *)
  48. (*                                                                      *)
  49. (*      Remarks:                                                        *)
  50. (*                                                                      *)
  51. (*         You can replace this with something smarter --- i.e.,        *)
  52. (*         a VT100 emulator, or whatever you like.                      *)
  53. (*                                                                      *)
  54. (*----------------------------------------------------------------------*)
  55.  
  56. VAR
  57.    Done: BOOLEAN           (* TRUE to exit terminal emulation mode *);
  58.    Ch  : CHAR              (* Character read/written               *);
  59.  
  60. BEGIN (* Emulate_Dumb_Terminal *)
  61.  
  62.    Save_Screen( Saved_Screen );
  63.    Draw_Menu_Frame( 10, 10, 55, 15, Menu_Frame_Color,
  64.                     Menu_Text_Color, '' );
  65.  
  66.    WRITELN('Beginning Dumb Terminal Emulation');
  67.    DELAY( One_Second_Delay );
  68.  
  69.    Restore_Screen( Saved_Screen );
  70.    Reset_Global_Colors;
  71.  
  72.    Auto_Wrap_Mode := TRUE;
  73.    Done           := FALSE;
  74.                                    (* Loop over input until done *)
  75.    WHILE ( NOT Done ) DO
  76.       BEGIN
  77.                                    (* Check for character typed at keyboard *)
  78.          IF KeyPressed THEN
  79.             BEGIN
  80.  
  81.                READ( Kbd , Ch );
  82.  
  83.                CASE ORD( Ch ) OF
  84.  
  85.                   ESC:  IF KeyPressed THEN
  86.                            BEGIN
  87.                               Process_Command( Ch, FALSE, PibTerm_Command );
  88.                               IF PibTerm_Command <> Null_Command THEN
  89.                                  Execute_Command( PibTerm_Command, Done, FALSE );
  90.                            END
  91.                         ELSE
  92.                            BEGIN
  93.                               IF Local_Echo THEN WRITE( Ch );
  94.                               Async_Send( Ch );
  95.                            END;
  96.  
  97.                   BS:   BEGIN
  98.                            Ch := BS_Char;
  99.                            IF Local_Echo THEN WRITE( Ch );
  100.                            Async_Send( Ch );
  101.                         END;
  102.  
  103.                   DEL:  BEGIN
  104.                            Ch := Ctrl_BS_Char;
  105.                            IF Local_Echo THEN WRITE( Ch );
  106.                            Async_Send( Ch );
  107.                         END;
  108.  
  109.                   ELSE
  110.                         BEGIN
  111.                            IF Local_Echo THEN WRITE( Ch );
  112.                            Async_Send( Ch );
  113.                         END;
  114.  
  115.                END (* CASE ORD( Ch ) *);
  116.  
  117.             END;
  118.  
  119.          IF ( Script_File_Mode AND ( NOT ( Done OR Really_Wait_String ) ) ) THEN
  120.             BEGIN
  121.                Get_Script_Command( PibTerm_Command );
  122.                Execute_Command   ( PibTerm_Command , Done , TRUE );
  123.             END;
  124.  
  125.                                    (* Process character from remote *)
  126.          IF Async_Receive( Ch ) THEN
  127.             BEGIN
  128.                                    (* Check if XOFF needs to be sent *)
  129.                Async_Buffer_Full;
  130.  
  131.                                    (* Display the character received *)
  132.  
  133.                Display_Character( TrTab[Ch] );
  134.  
  135.             END
  136.                                    (* Check if waitstring time exhausted *)
  137.          ELSE
  138.             IF Really_Wait_String THEN
  139.                Check_Wait_String_Time;
  140.  
  141.       END;
  142.  
  143. END   (* Emulate_Dumb_Terminal *);
  144.